﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:dxdb="clr-namespace:UColor.WPF"
                    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
                    xmlns:helpers="clr-namespace:UColor.WPF.Helpers"
                    xmlns:ddhelpers="clr-namespace:UColor.Core.Helpers;assembly=UColor.Core"
                    xmlns:dxl="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style TargetType="ListBox" x:Key="RelatedLinkListBox">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <ItemsPresenter Margin="0,4"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <!--BEGIN WPF-->
                    <WrapPanel Orientation="Vertical" />
                    <!--END WPF-->
                    <!--ONLY SL<dx:WrapPanel Orientation="Vertical"/>ONLY SL-->
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="Button" x:Key="RelatedLinkButton">
        <Setter Property="Cursor" Value="Hand" />
        <Setter Property="dx:FocusHelper2.Focusable" Value="False" />
        <Setter Property="Width" Value="213" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Grid Margin="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image ddhelpers:GeneralizedUriHelper.Source="{Binding Icon}" Margin="0,0,4,1" />
                        <TextBlock Grid.Column="1" Text="{Binding Title.TextAsync}" VerticalAlignment="Center" HorizontalAlignment="Left" TextDecorations="Underline" TextWrapping="Wrap" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ListBoxItem" x:Key="RelatedLinkItemContainerStyle">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Button Command="{Binding ClickCommand}" Style="{StaticResource RelatedLinkButton}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ListBoxItem" x:Key="RelatedLinkGroupContainerStyle">
        <Setter Property="HorizontalAlignment" Value="Left" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid Margin="0,2">
                        <ListBox ItemsSource="{Binding}" 
                             Style="{StaticResource RelatedLinkListBox}" ItemContainerStyle="{StaticResource RelatedLinkItemContainerStyle}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="dxdb:RelatedLinkControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="dxdb:RelatedLinkControl">
                    <ListBox ItemsSource="{Binding Path=Links, RelativeSource={RelativeSource TemplatedParent}}"
                             Style="{StaticResource RelatedLinkListBox}" ItemContainerStyle="{StaticResource RelatedLinkGroupContainerStyle}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>